#!/usr/bin/env bash
# Test stub for `git`. Logs the call; branch + diff results are env-configured.
# v2 (Cycle 12) drops the push tracking — the issue-anchor protocol has no
# `git push` side effect, so STUB_PUSH_RC is gone. STUB_DIRTY remains so the
# warn-not-refuse dirty-worktree path (case 23) can be exercised.
set -euo pipefail

printf 'git %s\n' "$*" >> "${GIT_CALLS:-/dev/null}"

case "$1 ${2:-}" in
  "rev-parse --abbrev-ref")     printf '%s' "${STUB_BRANCH:-feature/x}" ;;
  "diff --quiet")                exit "${STUB_DIRTY:-0}" ;;
  "diff --cached")               exit "${STUB_DIRTY:-0}" ;;
  "status --porcelain")          printf '%s' "${STUB_PORCELAIN:-}" ;;
  *) : ;;
esac
exit 0
